package com.jianjun.ktui

import androidx.compose.material3.CalendarLocale
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.ui.text.intl.Locale

class WasmPlatform : Platform {
    override val name: String = "Web with Kotlin/Wasm"
}

actual fun getPlatform(): Platform = WasmPlatform()

@Suppress("UNCHECKED_CAST")
actual suspend fun <T> httpRuoYi(
    path: String,
    params: MutableMap<String, Any>,
    method: Method
): T {
    params["测试"] = "1"
    throw Exception("暂未实现" + getPlatform().urlRuoYi + path + jsJsonStringify(params.toString()))
}

@OptIn(markerClass = [ExperimentalMaterial3Api::class])
actual fun defaultLocale(): CalendarLocale {
    return Locale.current
}


@OptIn(ExperimentalWasmJsInterop::class)
@JsFun("(params) => JSON.stringify(params)")
internal external fun jsJsonStringify(params: String): String
